package com.dingdang.controller;

import com.dingdang.data.Result;
import com.dingdang.entity.Car;
import com.dingdang.service.CollectServiceI;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("collect")
@Api(value = "收藏接口")
public class CollectController {
   @Resource
   private CollectServiceI collectServiceI;


//收藏展示
    @GetMapping
    @ApiOperation("收藏的展示")
    @ApiImplicitParam(name = "uid",value = "用户id" ,paramType = "query",required = true)
    public Result findCollectCar(@RequestParam("uid") Long uid){
        List<Car> carList= collectServiceI.findCollectCar(uid);
        return Result.ok().setData(carList);
    }
//    收藏
    @PostMapping
    @ApiOperation(value = "收藏")
    @ApiImplicitParam(name = "carId",value = "每辆车对应的id",paramType = "query",required = true)
    public Result addCollectCar(HttpServletRequest request,@RequestParam("carId") Long carId){
        collectServiceI.addCollectCar(request,carId);
        return Result.ok();
    }
}
